package com.friday.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.friday.bo.MessageBo;
import com.friday.bo.impl.MessageBoImpl;
import com.friday.po.Message;

public class GetMessageServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		System.out.println("GetMessageServlet");
		HttpSession session = request.getSession();
		String account = (String)session.getAttribute("account");
		MessageBo msgBo = new MessageBoImpl();
		try {
			List<Message> msgs = msgBo.getAllMessageByAccount(account);
			session.setAttribute("newmessage", msgs);
		} catch (Exception e) {
			e.printStackTrace();
		}
		response.sendRedirect("MyMessage.jsp");
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
